package easy.id_0_100;

public class lee58 {
    public static void main(String[] args) {
        String str="joyboy";
        System.out.println(lengthOfLastWord(str));
    }
    public static int lengthOfLastWord(String s) {
        int right=s.length()-1;
        int i=right;
        while (i>=0  && s.charAt(i)==' ') {
            i--;
        }
        right=i;
        while (i>=0 && s.charAt(i)!=' ') {
            i--;
        }
        return right-i;
    }
}
